module.exports = function($scope, $state, $stateParams, $modalInstance, $resource,$modal,FileUploader,toaster,item){
    $scope.info = item;
    if(item){
        var id = item.id;        
    }
    // console.log(id);
     // 广告图片
    var uploader1 = $scope.uploader1 = new FileUploader({
        url: 'http://cl.juyouhx.com/oss.php/oss/webuploader1?topdir=aa&selfdir=bb'
    });

    uploader1.filters.push({
        name: 'imageFilter',
        fn: function(item /*{File|FileLikeObject}*/, options) {
            var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
            return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
        }
    });    
    uploader1.onSuccessItem = function(fileItem, response, status, headers) {
        $scope.info.url = response.savename; 

    };
	$scope.ok = function(){
        var url = '';
        if(id){
            url = '/api/as/ac/activeSeeAd/updateSeeAdAd';
        } else {
            url = '/api/as/ac/activeSeeAd/saveSeeAdAd';
        }
		$resource(url, {}, {}).
		save($scope.info, function(res){
			console.log($scope.info);
			if(res.errcode === 0)
			{
                toaster.success({title:"",body:"操作成功"});
				$modalInstance.close();
			}
			else
			{
                toaster.error({title:"",body:res.errmsg});				
			}
 
		});

	}
    $scope.cancel = function(){
		$modalInstance.close();
	}




};